<%@ page language="java" %>
<%
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("max-age", 0);
    response.setDateHeader("Expires", 0);
%>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<html>

<HEAD>
	<TITLE>Scalar Soft - ChipTrac - Transit Lot Numbers </TITLE>
    <META http-equiv='Content-Type' content='text/html; charset=windows-1252'>
    <LINK href='<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css' type='text/css' rel='stylesheet'>

<script language='javascript' >

function save()
{
    var pa1=document.getElementById("tderrors");
    var pa=document.getElementById("errors");
    pa1.innerHTML               = '';
    pa.innerHTML                = '';
    var form                    = document.assmReleaseForm;
    var selectedLotsObj         = form.hiddenLot;
    var count1                  = 0;

    if( typeof( selectedLotsObj.length ) == "undefined" )
    {
        if( form['transitLotsList[0].checked'].checked == true )
        {
            if ( form['transitLotsList[0].moveTo'].value =='-1')
            {
               pa.innerHTML = "<li> Please select DieBank Vendor locations";
               form['transitLotsList['+i+'].moveTo'].focus(); 
               return;
            }
            else
            {
               count1 = count1+1;
            }
        }
    }
    else
    {
        for( var i=0; i < selectedLotsObj.length; i++ )
        {
            if( form['transitLotsList['+i+'].checked'].checked == true )
            {
               if ( form['transitLotsList['+i+'].moveTo'].value == '-1')
               {
                    pa.innerHTML = "<li> Please select DieBank Vendor locations";
                    form['transitLotsList['+i+'].moveTo'].focus();
                    return;
               }
               else
               {
                   count1++;
               }
            }
        }
    }

    if( count1==0 )
	{
		pa.innerHTML = "<li> Please select atleast one lot";
		return;
	}

    document.assmReleaseForm.action="<%=chipTracContext%>/newAssmRelease.do?action=saveTransitLots";
	pa1.innerHTML = '<li> Please wait request is in Process...........';
	document.getElementById("SaveButton").href = "#";
    document.assmReleaseForm.submit();
}

/*To reset the Values */
function reset()
{
    document.assmReleaseForm.reset();
}
/*if deselect the checkbox, to deselect the SelectAll checkbox*/
function deSelectLot()
{
    var pa1=document.getElementById("tderrors");
    var pa=document.getElementById("errors");

    pa.innerHTML                = '';
    pa1.innerHTML               = '';

    var selectedLotsObj         = document.assmReleaseForm.hiddenLot;
    var selAll                  = document.assmReleaseForm.seclectAll;

	// if there was only 1 checked then previously there was a problem thus this code below
	if (typeof selectedLotsObj.length =='undefined')
    {
          if( document.assmReleaseForm['transitLotsList[0].checked'].checked == true )
          {
            document.assmReleaseForm.select_top.checked = true;
            document.assmReleaseForm.select_bottom.checked = true;
            return;
          }
          else
          {
            document.assmReleaseForm.select_top.checked = false;
            document.assmReleaseForm.select_bottom.checked = false;
            return;
          }
    }

    for( var i=0; i< selectedLotsObj.length; i++ )
	{
		if(document.assmReleaseForm['transitLotsList[' + i + '].checked'].checked+""=='false')
		{
			document.assmReleaseForm.select_top.checked = false;
            document.assmReleaseForm.select_bottom.checked = false;
            return;
		}
        if(document.assmReleaseForm['transitLotsList[' + i + '].checked'].checked+""=='true')
		{
			document.assmReleaseForm.select_top.checked = true;
            document.assmReleaseForm.select_bottom.checked = true;

		}
    }
 }

/*To select all the checkboxs and deselect the all checkboxes*/
function setSelectAllIds(Object)
{
    var pa1=document.getElementById("tderrors");
    var pa=document.getElementById("errors");
    pa.innerHTML               = '';
    pa1.innerHTML               = '';

    var selectedLotsObj         = document.assmReleaseForm.hiddenLot;
    var count = 0;
    if (typeof Object.length =='undefined')
    {
      if(Object.checked == true )
      {
        document.assmReleaseForm.select_top.checked = true;
        document.assmReleaseForm.select_bottom.checked = true;
      }
      else
      {
        document.assmReleaseForm.select_top.checked = false;
        document.assmReleaseForm.select_bottom.checked = false;
      }
	}
    if (typeof Object.length =='undefined')
    {

       if( Object.checked == true )
       {
           document.assmReleaseForm['transitLotsList[0].checked'].checked = true;
           for ( count = 0; count < selectedLotsObj.length; count ++ )
           {
                document.assmReleaseForm['transitLotsList['+count+'].checked'].checked = true;
           }
        }
        else
        {
           document.assmReleaseForm['transitLotsList[0].checked'].checked = false;
           for ( count = 0; count < selectedLotsObj.length; count ++ )
           {
                document.assmReleaseForm['transitLotsList['+count+'].checked'].checked = false;
           }
        }
	}
}

function closeWindow()
{
    window.close();
}


</script>

</HEAD>
<logic:present name="closeWindowAfterSessionExp">
    <!--SESSION EXPIRED START-->
    <BODY bgcolor='ffffff' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0' >

        <TABLE cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%"  height="100%" align=center>
            <TR>
                <TD>
                    <TABLE align="center" border="0" width="40%" bgcolor="#FDF5E6">
                        <TR><TD>&nbsp;</TD></TR>
                        <TR><TD align="center" ><font class="NArialL"  color="red" > <b>Session has been time out , Please close this window and login again.</b></font></TD></TR>
                        <TR><TD>&nbsp;</TD></TR>
                        <TR><TD align="center" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></TD></TR>
                    </TABLE>
                </TD>
           </TR>
           <TR><TD>&nbsp;</TD></TR>
        </TABLE>

    </BODY>
    <!--SESSION EXPIRED END-->
</logic:present>
<logic:notPresent name="closeWindowAfterSessionExp">
<BODY bgcolor='ffffff' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0'>
<html:form  action="/newAssmRelease.do" method = "POST" type="com.scalar.chiptrack.operations.release.forms.AssmReleaseForm" >
<TABLE align='center' border='0' width='100%' >
    <TR>
        <td align='center' class="NArialW">Transit Lot Numbers</td>
    </TR>
    <TR>
        <TD align='center'>&nbsp;</TD>
        <TR><TD align="right" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></TD></TR>
    </TR>
    <tr><td align="center" colspan="10" class='NArialL'><FONT id="errors" color="#FF0000"></FONT></td></tr>
    <TR>
        <TD id = "tderrors" class='NArialL' style="color:green;" align = 'center'>
          <chiptrack:info styleClass="NArialL" />
          <chiptrack:errors styleClass="NArialL" />
        </TD>
    </TR>
    <TR>
        <TD align='center'>
			<TABLE align="center" border="0" width="50%">
                <bean:size id="LotsSize" name="assmReleaseForm"  property ='transitLotsList' />
                <logic:greaterThan name="LotsSize" value="0">
					<tr>
						<td colspan="10"class='NArialL'><font class='NArialS'><font color='blue'>[Click on Select checkbox to close Transit Lots]</font></font></td>
					</tr>
					<tr bgcolor="#993333" align = "center">
                        <td width="3%" class='NArialL'><FONT color="#FFFFFF" >Select </font></td>
						<td width="13%" nowrap class='NArialL'><FONT color="#FFFFFF" >Part Number</font></td>
                        <td width="10%" nowrap class='NArialL'><FONT color="#FFFFFF" >Lot No#</font></td>
                        <td width="10%" nowrap class='NArialL'><FONT color="#FFFFFF" >Process</font></td>
						<td width="10%" class='NArialL'><FONT color="#FFFFFF" >Ship Date</font></td>
						<td width="6%" class='NArialL'><FONT color="#FFFFFF" >Ship Qty</font></td>
                        <td width="6%" class='NArialL'><FONT color="#FFFFFF" >GDPW/<br>GoodDie</font></td>
                        <td width="8%" class='NArialL'><FONT color="#FFFFFF" >DieBank Vendor</font></td>
                        <td width="13%" class='NArialL'><FONT color="#FFFFFF" >Ship To</font></td>

                    </tr>
                    <tr bgcolor='#DEE1E2'>
						<td colspan="11" class='NArialL'><input type="checkbox" name="select_top" onClick = "javascript:setSelectAllIds(this)">&nbsp;&nbsp Select All</td>
					</tr>
                    <nested:iterate id="transitInfo" property="transitLotsList" indexId="iterateIdx" type="com.scalar.chiptrack.operations.dataentry.InTransitLots">

		            <tr bgcolor='<%=iterateIdx.intValue() % 2 == 0 ? "#FFFFEE" : "#DEE1E2"%>'>
		                <td width ="3%" class='NArialL' align="center"><nested:checkbox onclick = "javascript:deSelectLot()" name="transitInfo" property = "checked" ></nested:checkbox> </td>
                        <td class='NArialL'><nested:write name="transitInfo" property ="partNumber"/></td>
                        <td class='NArialL'><nested:write name="transitInfo" property ="lotNumber"/></td>
                        <td class='NArialL'><nested:write name="transitInfo" property ="processType"/></td>
                        <td class='NArialL'><nested:write name="transitInfo" property ="shipDate"/></td>
						<td class='NArialL'><nested:write name="transitInfo" property ="shipQty"/>
                        <input type="hidden" name="hiddenLot"> </font></td>
                        <td class='NArialL'><nested:write name="transitInfo" property ="grossDie"/></td>
                        <td nowrap class='NArialL'>
                            <nested:select name="transitInfo" property="moveTo" styleClass="txfield">
                                <html:option value="-1" >-- Select -- </html:option>
                                <html:options collection="dieBankVendorList" property="label" labelProperty="label"></html:options>
                            </nested:select>

                         </td>
                        <td nowrap class='NArialL'><nested:write name="transitInfo" property ="nextLocation"/></td>
                        <nested:hidden property="partNumber"/>
                        <nested:hidden property="lotNumber"/>
                        <nested:hidden property="shipQty"/>
                        <nested:hidden property="waferId"/>
                        <nested:hidden property="grossDie"/>
                        <nested:hidden property="fabLotNumber"/>
                    </tr>
                     </nested:iterate>
                    <tr bgcolor='#DEE1E2'>
						<td colspan="11" class='NArialL'><input type="checkbox" name="select_bottom" onClick = "javascript:setSelectAllIds(this)">&nbsp;&nbsp Select All</td>
					</tr>
                    <tr><td colspan='11'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td></tr>    
                    <tr>
                       <td align = "center" colspan ="11">
                            <a id = 'SaveButton' href="javascript:save()" onmouseover="window.status='Click here to Receive the Transit Lots';return true" onmouseout="window.status='';return true" title="Click here to Receive the Transit Lots">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a>&nbsp;&nbsp;
                            <a href="javascript:reset()" onmouseover="window.status='Click here to Reset the Transit Lots';return true" onmouseout="window.status='';return true" title="Click here to Reset the Transit Lots">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
                        </td>
                    </tr>
                    </table>
                    <br>
                    <TR><TD align="center" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></TD></TR>
        </logic:greaterThan>
        <logic:lessEqual name="LotsSize" value="0">
            <br><br><br><br>
                <center>
                <tr>
                    <td colspan="10" class='NArialL' align="center"><FONT  styleClass="NArialL" color="#FF0000">No Transit Lots are Found</FONT>
                    </td>
                </tr>
                </center>
        </logic:lessEqual>


    <TR><TD align='center'>&nbsp;</TD></TR>
</td>
</TABLE>
</html:form>
</BODY>
</logic:notPresent>
</html>
